<template>
  <el-dialog
    :before-close="handleClose"
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    :title="globalData.title"
    :visible.sync="isDialog.visible"
    top="7vh"
    width="1400px"
  >
    <div class="header-box"></div>

    <div class="flex-content">
      <el-table
        v-loading="isLoading.table"
        :data="dataList"
        style="width: 100%"
      >
        <el-table-column align="center" label="订单号" prop="order_sn">
        </el-table-column>

        <el-table-column
          align="center"
          label="下单用户"
          prop="member"
          show-overflow-tooltip
          width="200"
        >
        </el-table-column>

        <el-table-column
          align="center"
          label="下单商家"
          prop="provider"
          show-overflow-tooltip
          width="200"
        >
        </el-table-column>

        <el-table-column align="center" label="订单总金额" prop="order_fee">
        </el-table-column>

        <el-table-column align="center" label="结算金额" prop="settle_cash">
        </el-table-column>

        <el-table-column align="center" label="付款情况" prop="payInfo">
        </el-table-column>

        <el-table-column align="center" label="完结时间" prop="complete_time">
        </el-table-column>

        <el-table-column
          align="center"
          label="备注"
          prop="remark"
          show-overflow-tooltip
        >
        </el-table-column>
      </el-table>
    </div>

    <!-- 分页-->
    <div class="footer-box">
      <pagination
        :limit.sync="queryInfo.rows"
        :page.sync="queryInfo.page"
        :total="totalCount"
        @pagination="getData"
      >
      </pagination>
    </div>
  </el-dialog>
</template>

<script>
import { lists as getList } from "@/api/order";

export default {
  name: "Order",
  props: {
    info: {
      type: Object,
    },
  },
  data() {
    return {
      // 查询条件
      queryInfo: {
        page: 1,
        rows: 10,
        bs_id: 1,
        r_id: this.info.r_id,
      },
      // 统计
      dataList: [],
      // 总页数
      totalCount: 0,
      // 数据
      globalData: {
        title: "",
      },
      // 加载
      isLoading: {
        table: false,
      },
      // 弹窗
      isDialog: {
        visible: true,
      },
      // 防抖
      queryId: +new Date(),
    };
  },
  created() {
    this.getData();
    this.globalData.title = "对账订单" + "( " + this.info.period + ")";
  },
  methods: {
    // 详情
    getData() {
      this.isLoading.table = true;
      this.queryId++;
      let queryId = this.queryId;
      getList(this.queryInfo)
        .then((res) => {
          if (queryId !== this.queryId) {
            return;
          }
          this.dataList = res.data.list;
          this.totalCount = res.data.total;
        })
        .finally(() => {
          this.isLoading.table = false;
        });
    },
    // 关闭
    handleClose() {
      this.$emit("close");
    },
  },
};
</script>

<style lang="scss" scoped>
::v-deep .el-dialog__body {
  padding: 0 20px 20px 20px;
}

.header-box {
  display: flex;

  > div {
    margin-right: 10px;
  }
}

.flex-content {
  margin-top: 10px;

  .header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;

    .title {
      font-size: 18px;
      font-weight: bold;
    }
  }
}
</style>
